home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / JPG5A386.ZIP / usage.doc < prev    next >
Text File  |  1994-12-17  |  21KB  |  433 lines

  1. USAGE instructions for the Independent JPEG Group's JPEG software
  2. =================================================================
  3.  
  4. INTRODUCTION
  5.  
  6. These programs implement JPEG image compression and decompression.  JPEG
  7. (pronounced "jay-peg") is a standardized compression method for full-color
  8. and gray-scale images.  JPEG is designed to handle "real-world" scenes,
  9. for example scanned photographs.  Cartoons, line drawings, and other
  10. non-realistic images are not JPEG's strong suit; on that sort of material
  11. you may get poor image quality and/or little compression.
  12.  
  13. JPEG is lossy, meaning that the output image is not necessarily identical to
  14. the input image.  Hence you should not use JPEG if you have to have identical
  15. output bits.  However, on typical real-world images, very good compression
  16. levels can be obtained with no visible change, and amazingly high compression
  17. is possible if you can tolerate a low-quality image.  You can trade off image
  18. quality against file size by adjusting the compressor's "quality" setting.
  19.  
  20.  
  21. GENERAL USAGE
  22.  
  23. We provide two programs, cjpeg to compress an image file into JPEG format,
  24. and djpeg to decompress a JPEG file back into a conventional image format.
  25.  
  26. The basic command line is:
  27.     cjpeg [switches] list of image files
  28. or
  29.     djpeg [switches] list of jpeg files
  30.  
  31. Each file named is compressed or decompressed.  The input file(s) are not
  32. modified; the output data is written to files which have the same names
  33. except for extension.  cjpeg always uses ".jpg" for the output file name's
  34. extension; djpeg uses one of ".bmp", ".gif", ".ppm", ".rle", or ".tga",
  35. depending on what output format is selected by the switches.
  36.  
  37. For example, to convert xxx.gif to xxx.jpg and yyy.ppm to yyy.jpg, say:
  38.     cjpeg xxx.gif yyy.ppm
  39.  
  40. On most systems you can use standard wildcards to specify the list of input
  41. files; for example, on DOS "djpeg *.jpg" decompresses all the JPEG files in
  42. the current directory.
  43.  
  44. If an intended output file already exists, you'll be asked whether or not to
  45. overwrite it.  If you say no, the program skips that input file and goes on
  46. to the next one.
  47.  
  48. You can intermix switches and file names; for example
  49.     djpeg -gif file1.jpg -targa file2.jpg
  50. decompresses file1.jpg into GIF format (file1.gif) and file2.jpg into Targa
  51. format (file2.tga).  Only switches to the left of a given file name affect
  52. processing of that file; when there are conflicting switches, the rightmost
  53. one takes precedence.
  54.  
  55. You can override the program's choice of output file name by using the
  56. -outfile switch, as in
  57.     cjpeg -outfile output.jpg input.ppm
  58. -outfile only affects the first input file name to its right.
  59.  
  60. The currently supported image file formats are: PPM (PBMPLUS color format),
  61. PGM (PBMPLUS gray-scale format), BMP, GIF, Targa, and RLE (Utah Raster
  62. Toolkit format).  (RLE is supported only if the URT library is available,
  63. which it isn't on most non-Unix systems.)  cjpeg recognizes the input image
  64. format automatically, with the exception of some Targa-format files.  You
  65. have to tell djpeg which format to generate.
  66.  
  67. JPEG files are in the defacto standard JFIF file format.  There are other,
  68. less widely used JPEG-based file formats, but we don't support them.
  69.  
  70. All switch names may be abbreviated; for example, -grayscale may be written
  71. -gray or -gr.  Most of the "basic" switches can be abbreviated to as little as
  72. one letter.  Upper and lower case are equivalent (-GIF is the same as -gif).
  73. British spellings are also accepted (e.g., -greyscale), though for brevity
  74. these are not mentioned below.
  75.  
  76.  
  77. CJPEG DETAILS
  78.  
  79. The basic command line switches for cjpeg are:
  80.  
  81.     -quality N    Scale quantization tables to adjust image quality.
  82.             Quality is 0 (worst) to 100 (best); default is 75.
  83.             (See below for more info.)
  84.  
  85.     -grayscale    Create monochrome JPEG file from color input.
  86.             Be sure to use this switch when compressing a grayscale
  87.             GIF file, because cjpeg isn't bright enough to notice
  88.             whether a GIF file uses only shades of gray.  By
  89.             saying -grayscale, you'll get a smaller JPEG file that
  90.             takes less time to process.
  91.  
  92.     -optimize    Perform optimization of entropy encoding parameters.
  93.             Without this, default encoding parameters are used.
  94.             -optimize usually makes the JPEG file a little smaller,
  95.             but cjpeg runs somewhat slower and needs much more
  96.             memory.  Image quality and speed of decompression are
  97.             unaffected by -optimize.
  98.  
  99.     -targa        Input file is Targa format.  Targa files that contain
  100.             an "identification" field will not be automatically
  101.             recognized by cjpeg; for such files you must specify
  102.             -targa to make cjpeg treat the input as Targa format.
  103.             For most Targa files, you won't need this switch.
  104.  
  105. The -quality switch lets you trade off compressed file size against quality of
  106. the reconstructed image: the higher the quality setting, the larger the JPEG
  107. file, and the closer the output image will be to the original input.  Normally
  108. you want to use the lowest quality setting (smallest file) that decompresses
  109. into something visually indistinguishable from the original image.  For this
  110. purpose the quality setting should be between 50 and 95; the default of 75 is
  111. often about right.  If you see defects at -quality 75, then go up 5 or 10
  112. counts at a time until you are happy with the output image.  (The optimal
  113. setting will vary from one image to another.)
  114.  
  115. -quality 100 will generate a quantization table of all 1's, eliminating loss
  116. in the quantization step (but there is still information loss in subsampling,
  117. as well as roundoff error).  This setting is mainly of interest for
  118. experimental purposes.  Quality values above about 95 are NOT recommended for
  119. normal use; the compressed file size goes up dramatically for hardly any gain
  120. in output image quality.
  121.  
  122. In the other direction, quality values below 50 will produce very small files
  123. of low image quality.  Settings around 5 to 10 might be useful in preparing an
  124. index of a large image library, for example.  Try -quality 2 (or so) for some
  125. amusing Cubist effects.  (Note: quality values below about 25 generate 2-byte
  126. quantization tables, which are considered optional in the JPEG standard.
  127. cjpeg emits a warning message when you give such a quality value, because
  128. some commercial JPEG programs may be unable to decode the resulting file.
  129. Use -baseline if you need to ensure compatibility at low quality values.)
  130.  
  131. Switches for advanced users:
  132.  
  133.     -dct int    Use integer DCT method (default).
  134.     -dct fast    Use fast integer DCT (less accurate).
  135.     -dct float    Use floating-point DCT method.
  136.             The float method is very slightly more accurate than
  137.             the int method, but is much slower unless your machine
  138.             has very fast floating-point hardware.  Also note that
  139.             results of the floating-point method may vary slightly
  140.             across machines, while the integer methods should give
  141.             the same results everywhere.  The fast integer method
  142.             is much less accurate than the other two.
  143.  
  144.     -restart N    Emit a JPEG restart marker every N MCU rows, or every
  145.             N MCU blocks if "B" is attached to the number.
  146.             -restart 0 (the default) means no restart markers.
  147.  
  148.     -smooth N    Smooth the input image to eliminate dithering noise.
  149.             N, ranging from 1 to 100, indicates the strength of
  150.             smoothing.  0 (the default) means no smoothing.
  151.  
  152.     -maxmemory N    Set limit for amount of memory to use in processing
  153.             large images.  Value is in thousands of bytes, or
  154.             millions of bytes if "M" is attached to the number.
  155.             For example, -max 4m selects 4000000 bytes.  If more
  156.             space is needed, temporary files will be used.
  157.  
  158.     -verbose    Enable debug printout.  More -v's give more printout.
  159.     or  -debug    Also, version information is printed at startup.
  160.  
  161. The -restart option inserts extra markers that allow a JPEG decoder to
  162. resynchronize after a transmission error.  Without restart markers, any damage
  163. to a compressed file will usually ruin the image from the point of the error
  164. to the end of the image; with restart markers, the damage is usually confined
  165. to the portion of the image up to the next restart marker.  Of course, the
  166. restart markers occupy extra space.  We recommend -restart 1 for images that
  167. will be transmitted across unreliable networks such as Usenet.
  168.  
  169. The -smooth option filters the input to eliminate fine-scale noise.  This is
  170. often useful when converting GIF files to JPEG: a moderate smoothing factor of
  171. 10 to 50 gets rid of dithering patterns in the input file, resulting in a
  172. smaller JPEG file and a better-looking image.  Too large a smoothing factor
  173. will visibly blur the image, however.
  174.  
  175. Switches for wizards:
  176.  
  177.     -arithmetic    Use arithmetic coding rather than Huffman coding.
  178.             (Not currently supported for legal reasons.)
  179.  
  180.     -baseline    Force a baseline JPEG file to be generated.  This
  181.             clamps quantization values to 8 bits even at low
  182.             quality settings.
  183.  
  184.     -nointerleave    Generate noninterleaved JPEG file (not yet supported).
  185.  
  186.     -qtables file    Use the quantization tables given in the specified
  187.             file.  The file should contain one to four tables
  188.             (64 values each) as plain text.  Comments preceded by
  189.             '#' may be included in the file.  The tables are
  190.             implicitly numbered 0,1,etc.  If -quality N is also
  191.             specified, the values in the file are scaled according
  192.             to cjpeg's quality scaling curve.
  193.  
  194.     -qslots N[,...] Select which quantization table to use for each color
  195.             component.  By default, table 0 is used for luminance
  196.             and table 1 for chrominance components.
  197.  
  198.     -sample HxV[,...]    Set JPEG sampling factors.  If you specify
  199.             fewer H/V pairs than there are components, the
  200.             remaining components are set to 1x1 sampling.  The
  201.             default setting is equivalent to "-sample 2x2".
  202.  
  203. The "wizard" switches are intended for experimentation with JPEG.  If you
  204. don't know what you are doing, DON'T USE THEM.  You can easily produce files
  205. with worse image quality and/or poorer compression than you'll get from the
  206. default settings.  Furthermore, these switches should not be used when making
  207. files intended for general use, because not all JPEG implementations will
  208. support unusual JPEG parameter settings.
  209.  
  210.  
  211. DJPEG DETAILS
  212.  
  213. The basic command line switches for djpeg are:
  214.  
  215.     -colors N    Reduce image to at most N colors.  This reduces the
  216.     or -quantize N    number of colors used in the output image, so that it
  217.             can be displayed on a colormapped display or stored in
  218.             a colormapped file format.  For example, if you have
  219.             an 8-bit display, you'd need to reduce to 256 or fewer
  220.             colors.  (-colors is the recommended name, -quantize
  221.             is provided only for backwards compatibility.)
  222.  
  223.     -fast        Select recommended processing options for fast, low
  224.             quality output.  (The default options are chosen for
  225.             highest quality output.)  Currently, this is equivalent
  226.             to "-dct fast -nosmooth -onepass -dither ordered".
  227.  
  228.     -grayscale    Force gray-scale output even if JPEG file is color.
  229.             Useful for viewing on monochrome displays; also,
  230.             djpeg runs noticeably faster in this mode.
  231.  
  232.     -scale M/N    Scale the output image by a factor M/N.  Currently
  233.             the scale factor must be 1/1, 1/2, 1/4, or 1/8.
  234.             Scaling is handy if the image is larger than your
  235.             screen; also, djpeg runs much faster when scaling
  236.             down the output.
  237.  
  238.     -bmp        Select BMP output format (Windows flavor).  8-bit
  239.             colormapped format is emitted if -colors or -grayscale
  240.             is specified, or if the JPEG file is gray-scale;
  241.             otherwise, 24-bit full-color format is emitted.
  242.  
  243.     -gif        Select GIF output format (this is the default).
  244.             Since GIF does not support more than 256 colors,
  245.             -colors 256 is assumed (unless you specify a smaller
  246.             number of colors).  If you specify -fast, the
  247.             default number of colors is 216.
  248.  
  249.     -os2        Select BMP output format (OS/2 1.x flavor).  8-bit
  250.             colormapped format is emitted if -colors or -grayscale
  251.             is specified, or if the JPEG file is gray-scale;
  252.             otherwise, 24-bit full-color format is emitted.
  253.  
  254.     -pnm        Select PBMPLUS (PPM/PGM) output format.  PGM is
  255.             emitted if the JPEG file is gray-scale or if
  256.             -grayscale is specified; otherwise PPM is emitted.
  257.  
  258.     -rle        Select RLE output format.  (Requires URT library.)
  259.  
  260.     -targa        Select Targa output format.  Gray-scale format is
  261.             emitted if the JPEG file is gray-scale or if
  262.             -grayscale is specified; otherwise, colormapped format
  263.             is emitted if -colors is specified; otherwise, 24-bit
  264.             full-color format is emitted.
  265.  
  266. Switches for advanced users:
  267.  
  268.     -dct int    Use integer DCT method (default).
  269.     -dct fast    Use fast integer DCT (less accurate).
  270.     -dct float    Use floating-point DCT method.
  271.             The float method is very slightly more accurate than
  272.             the int method, but is much slower unless your machine
  273.             has very fast floating-point hardware.  Also note that
  274.             results of the floating-point method may vary slightly
  275.             across machines, while the integer methods should give
  276.             the same results everywhere.  The fast integer method
  277.             is much less accurate than the other two.
  278.  
  279.     -dither fs    Use Floyd-Steinberg dithering in color quantization.
  280.     -dither ordered    Use ordered dithering in color quantization.
  281.     -dither none    Do not use dithering in color quantization.
  282.             By default, Floyd-Steinberg dithering is applied when
  283.             quantizing colors; this is slow but usually produces
  284.             the best results.  Ordered dither is a compromise
  285.             between speed and quality; no dithering is fast but
  286.             usually looks awful.  Note that these switches have
  287.             no effect unless color quantization is being done.
  288.             Ordered dither is only available in -onepass mode.
  289.  
  290.     -map FILE    Quantize to the colors used in the specified image
  291.             file.  This is useful for producing multiple files
  292.             with identical color maps, or for forcing a predefined
  293.             set of colors to be used.  The FILE must be a GIF
  294.             or PPM file.  This option overrides -colors and
  295.             -onepass.
  296.  
  297.     -nosmooth    Use a faster, lower-quality upsampling routine.
  298.  
  299.     -onepass    Use one-pass instead of two-pass color quantization.
  300.             The one-pass method is faster and needs less memory,
  301.             but it produces a lower-quality image.  -onepass is
  302.             ignored unless you also say -colors N.  Also,
  303.             the one-pass method is always used for gray-scale
  304.             output (the two-pass method is no improvement then).
  305.  
  306.     -maxmemory N    Set limit for amount of memory to use in processing
  307.             large images.  Value is in thousands of bytes, or
  308.             millions of bytes if "M" is attached to the number.
  309.             For example, -max 4m selects 4000000 bytes.  If more
  310.             space is needed, temporary files will be used.
  311.  
  312.     -verbose    Enable debug printout.  More -v's give more printout.
  313.     or  -debug    Also, version information is printed at startup.
  314.  
  315.  
  316. HINTS FOR CJPEG
  317.  
  318. Color GIF files are not the ideal input for JPEG; JPEG is really intended for
  319. compressing full-color (24-bit) images.  In particular, don't try to convert
  320. cartoons, line drawings, and other images that have only a few distinct
  321. colors.  GIF works great on these, JPEG does not.  If you want to convert a
  322. GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options
  323. to get a satisfactory conversion.  -smooth 10 or so is often helpful.
  324.  
  325. Avoid running an image through a series of JPEG compression/decompression
  326. cycles.  Image quality loss will accumulate; after ten or so cycles the image
  327. may be noticeably worse than it was after one cycle.  It's best to use a
  328. lossless format while manipulating an image, then convert to JPEG format when
  329. you are ready to file the image away.
  330.  
  331. The -optimize option to cjpeg is worth using when you are making a "final"
  332. version for posting or archiving.  It's also a win when you are using low
  333. quality settings to make very small JPEG files; the percentage improvement
  334. is often a lot more than it is on larger files.
  335.  
  336.  
  337. HINTS FOR DJPEG
  338.  
  339. To get a quick preview of an image, use the -grayscale and/or -scale switches.
  340. "-grayscale -scale 1/8" is the fastest case.
  341.  
  342. Several options are available that trade off image quality to gain speed.
  343. "-fast" turns on the recommended settings.
  344.  
  345. "-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality.
  346. When producing a color-quantized image, "-onepass -dither ordered" is fast but
  347. much lower quality than the default behavior.  "-dither none" may give
  348. acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
  349.  
  350. If you are fortunate enough to have very fast floating point hardware,
  351. "-dct float" may be even faster than "-dct fast".  But on most machines
  352. "-dct float" is slower than "-dct int"; in this case it is not worth using,
  353. because its theoretical accuracy advantage is too small to be significant
  354. in practice.
  355.  
  356. Two-pass color quantization requires a good deal of memory; on MS-DOS machines
  357. it may run out of memory even with -maxmemory 0.  In that case you can still
  358. decompress, with some loss of image quality, by specifying -onepass for
  359. one-pass quantization.
  360.  
  361.  
  362. HINTS FOR BOTH PROGRAMS
  363.  
  364. If more space is needed than will fit in the available main memory (as
  365. determined by -maxmemory), temporary files will be used.  (MS-DOS versions
  366. will try to get extended or expanded memory first.)  The temporary files are
  367. often rather large: in typical cases they occupy three bytes per pixel, for
  368. example 3*800*600 = 1.44Mb for an 800x600 image.  If you don't have enough
  369. free disk space, leave out -optimize (for cjpeg) or specify -onepass (for
  370. djpeg).
  371.  
  372. On MS-DOS, the temporary files are created in the directory named by the TMP
  373. or TEMP environment variable, or in the current directory if neither of those
  374. exist.  Amiga implementations put the temp files in the directory named by
  375. JPEGTMP:, so be sure to assign JPEGTMP: to a disk partition with adequate free
  376. space.
  377.  
  378. On MS-DOS machines, -maxmemory is the amount of main (conventional) memory to
  379. use.  (Extended or expanded memory is also used if available.)  Most
  380. DOS-specific versions of this software do their own memory space estimation
  381. and do not need you to specify -maxmemory.
  382.  
  383.  
  384. THE COMMENT UTILITIES
  385.  
  386. The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
  387. Although the standard doesn't actually define what COM blocks are for, they
  388. are widely used to hold user-supplied text strings.  This lets you add
  389. annotations, titles, index terms, etc to your JPEG files, and later retrieve
  390. them as text.  COM blocks do not interfere with the image stored in the JPEG
  391. file.  The maximum size of a COM block is 64K, but you can have as many of
  392. them as you like in one JPEG file.
  393.  
  394. We provide two utility programs to display COM block contents and add COM
  395. blocks to a JPEG file.
  396.  
  397. rdjpgcom searches a JPEG file and prints the contents of any COM blocks on
  398. standard output.  The command line syntax is
  399.     rdjpgcom [-verbose] [inputfilename]
  400. The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG
  401. image dimensions.  If you omit the input file name from the command line,
  402. the JPEG file is read from standard input.  (This may not work on some
  403. operating systems, if binary data can't be read from stdin.)
  404.  
  405. wrjpgcom adds a COM block, containing text you provide, to a JPEG file.
  406. Ordinarily, the COM block is added after any existing COM blocks, but you
  407. can delete the old COM blocks if you wish.  wrjpgcom produces a new JPEG
  408. file; it does not modify the input file.  DO NOT try to overwrite the input
  409. file by directing wrjpgcom's output back into it; on most systems this will
  410. just destroy your file.
  411.  
  412. The command line syntax for wrjpgcom is
  413.     wrjpgcom [switches] inputfilename outputfilename
  414. where both input and output file names must be given explicitly.
  415.  
  416. wrjpgcom understands three switches:
  417.     -replace         Delete any existing COM blocks from the file.
  418.     -comment "Comment text"     Supply new COM text on command line.
  419.         -cfile name         Read text for new COM block from named file.
  420. (Switch names can be abbreviated.)  If you have only one line of comment text
  421. to add, you can provide it on the command line with -comment.  The comment
  422. text must be surrounded with quotes so that it is treated as a single
  423. argument.  Longer comments can be read from a text file.
  424.  
  425. If you give neither -comment nor -cfile, then wrjpgcom will read the comment
  426. text from standard input.  You can enter multiple lines, up to 64KB worth.
  427. Type an end-of-file indicator (control-Z) to terminate the comment text
  428. entry.
  429.  
  430. wrjpgcom will not add a COM block if the provided comment string is empty.
  431. Therefore -replace -comment "" can be used to delete all COM blocks from a
  432. file.
  433.